/* 
 * File:   Visualizer.h
 * Author: cjjonker
 *
 * Created on 20 december 2012, 15:06
 */

#ifndef VISUALIZER_H
#define	VISUALIZER_H

#include <string>
#include "ColorLegend.h"
#include "ColorMap.h"
#include "Simulation.h"

class Visualizer {
    
    bool d_isactive;
   
        
    public:
        Visualizer();
        Visualizer(std::string &name);

        void toggleActive();
        bool isActive();
        void setActive(bool a);
        void setSimulation(Simulation *sim);
        
        void setCurrentAppearance(int id);
        
        void setCurrentMapDataset();
        void setCurrentMapDataset(int id);
        
        void setCurrentMapColormode(int id);
        void setCurrentMapScalemode(int id);
        
        void setCurrentVectorDataset();
        void setCurrentVectorDataset(int id);
        
        void setColormapHue(float h);
        void setColormapSat(float s);
        void setColormapVal(float v);
        void setColormapLevels(float l);
        float getColormapHue();
        float getColormapSat();
        float getColormapVal();
        float getColormapLevels();
        
        bool usesColormap();
        bool usesVectorDataset();
        bool hasMultipleAppearances();
        
        std::string getName();
        
        std::vector<std::string> getColormapDatasets();
        std::vector<std::string> getColorModeNames();
        std::vector<std::string> getScaleModeNames();
        std::vector<std::string> getVectorDatasetNames();
        std::vector<std::string> getAppearancesNames();
        
        

        virtual void draw(int winW, int winH)=0;

    protected: 
        enum ColorMapDatasets
        {
            Rho,V,F,GradientMagnitudeRho,GradientMagnitudeV,AngleV,AngleF,GradientAngleRho,GradientAngleV,ColorMapDatasetsCount
        };
        
        enum VectorDatasets
        {
            Flow, Force, GradientRho, GradientV, DatasetCount
        };
                
        virtual void init();
        
        ScalarDataset *d_map_dataset;
        
        VectorDataset *d_vector_dataset;
        int d_current_vector_dataset_index;
        
        int d_appearance;
        
        Simulation *d_simulation;
        std::string d_name;
        ColorLegend d_legend;
        ColorMap d_map;
        
        bool d_uses_colormap;
        bool d_uses_vector_dataset; //if this visualizer uses a dataset other than colormap
        
        bool d_has_multiple_appearances;
        
        bool d_normalize;
        double d_scale;
        
        
        void setColormapMinMax();
        void setGLColor(int idx);
        void setGLColor(float x, float y);
        
        int d_current_map_dataset_index;        
        std::vector<std::string> d_map_dataset_names;
        std::vector<std::string> d_vector_dataset_names;
        std::vector<std::string> d_multiple_appearances;

    private:

};

inline bool Visualizer::usesColormap() { return d_uses_colormap; }

inline void Visualizer::toggleActive() { d_isactive = !d_isactive; }

inline void Visualizer::setActive(bool a) { d_isactive = a; }

inline bool Visualizer::isActive() { return d_isactive; }

inline void Visualizer::setSimulation(Simulation *sim) { d_simulation = sim; init(); }

inline std::string Visualizer::getName() { return d_name; }

inline std::vector<std::string> Visualizer::getColormapDatasets() { return d_map_dataset_names; }

inline std::vector<std::string> Visualizer::getColorModeNames() { return d_map.colorModeNames(); }

inline std::vector<std::string> Visualizer::getScaleModeNames() { return d_map.scaleModeNames(); }

inline void Visualizer::setCurrentMapColormode(int id) { d_map.colorMode(id); }

inline void Visualizer::setCurrentMapScalemode(int id) { d_map.scaleMode(id); }

inline bool Visualizer::usesVectorDataset() { return d_uses_vector_dataset; }

inline std::vector<std::string> Visualizer::getVectorDatasetNames() { return d_vector_dataset_names; }

inline std::vector<std::string> Visualizer::getAppearancesNames() { return d_multiple_appearances; }

inline void Visualizer::setColormapSat(float s) { d_map.saturation(s); }

inline void Visualizer::setColormapVal(float v) { d_map.value(v); }

inline void Visualizer::setColormapHue(float h) { d_map.hue(h); }

inline void Visualizer::setColormapLevels(float l) { d_map.levels(l); }

inline float Visualizer::getColormapHue() { return d_map.hue(); }

inline float Visualizer::getColormapSat() { return d_map.saturation(); }

inline float Visualizer::getColormapLevels() { return d_map.levels(); }

inline float Visualizer::getColormapVal() { return d_map.value(); }

inline bool Visualizer::hasMultipleAppearances() { return d_has_multiple_appearances; }

#endif	/* VISUALIZER_H */

